
package org.movee.spring.data.hugegraph.mapping;

import org.movee.spring.data.hugegraph.annotation.EdgeHead;
import org.movee.spring.data.hugegraph.annotation.EdgeTail;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;

public class BasicHugePersistentProperty extends AnnotationBasedPersistentProperty<HugePersistentProperty>
        implements HugePersistentProperty {

    public BasicHugePersistentProperty(Property property,
                                       HugePersistentEntity<?> owner,
                                       SimpleTypeHolder holder) {
        super(property, owner, holder);
    }

    @Override
    protected Association<HugePersistentProperty> createAssociation() {
        return new Association<>(this, null);
    }

    /**
     * id field must annonated by @Id
     * @return
     */
    @Override
    public boolean isIdProperty() {
        return super.isIdProperty();
    }


    @Override
    public Boolean isEdgeHeadProperty() {
        return isAnnotationPresent(EdgeHead.class);
    }

    @Override
    public Boolean isEdgeTailProperty() {
        return isAnnotationPresent(EdgeTail.class);
    }
}
